import CatMap from "./2d/tilemap";
import GUI from "./gui/gui";
import CoinAreaObj from "./obj/coin_area_obj";
import GrassStaticObj from "./obj/grass_static_obj";
import IconKObj from "./obj/icon_k_obj";
import IconRigidObj from "./obj/icon_r_obj";
import BaseMove from "./sprite/base_move";
import IconSprite  from "./sprite/icon_sprite"
import KnightAniSpr from "./sprite/knight_anisprite";
import KnightMove from "./sprite/knight_move";
import KnightSprite from "./sprite/knigt_sprite";
import MySprite from "./sprite/my_sprite";
import PlayerSprite from "./sprite/player_sprite";

export default class Game extends godot.Node2D {

	// Called when the node enters the scene tree for the first time.
	_ready() {
		// this.initSpr()
		// this.initIcon();
		// this.initKnight();
		// this.initPlayer();
		// this.initAniSpr();
		// this.initMoveSpr();
		// this.baseControl()
		// this.initContainer()

		// this.initMySpr()

		// this.initAreaObj()
		// this.initKObj()
		// this.initRObj()

		this.initTileMap();
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	_process(delta) {

	}

	initSpr() {
		let spr = new godot.Sprite()
		spr.texture = godot.load("res://icon.png") as godot.Texture;
		this.add_child(spr);
	}

	initIcon(){
		this.add_child(new IconSprite());
	}

	initKnight(){
		this.add_child(new KnightSprite())
	}
	initPlayer(){
		this.add_child(new PlayerSprite())
	}
	initAniSpr(){
		this.add_child(new KnightAniSpr())
	}
	initMoveSpr(){
		this.add_child(new KnightMove())
	}
	initMySpr(){
		let spr = new MySprite()
		spr.texture = godot.load("res://icon.png") as godot.Texture;
		this.add_child(spr);
	}


	initAreaObj(){
		// 注册一个可移动的
		let moveIcon = new CoinAreaObj(300,300,"res://icon.png")
		moveIcon.setConnect()

		let baseMove = new BaseMove()
		baseMove.x = 300
		baseMove.y = 300
		baseMove.isInputMove = true;
		moveIcon.add_child(baseMove)

		this.add_child(moveIcon)

		this.add_child(new CoinAreaObj())
	}

	initKObj(){
		// 注册一个可移动的KObj
		let moveIcon = new IconKObj(300,300,"res://assets/stand.png")
		this.add_child(moveIcon)

		// 注册一个Area2D
		let coinObj = new CoinAreaObj()
		coinObj.setConnect()
		this.add_child(coinObj)

		// 注册一个Static2D
		let grass2D = new GrassStaticObj(500,500,"res://assets/grass.png")
		this.add_child(grass2D)
	}

	initRObj(){
		// 注册一个可移动的KObj
		let moveIcon = new IconKObj(300,300,"res://assets/stand.png")
		this.add_child(moveIcon)

		// 注册一个Area2D
		let coinObj = new CoinAreaObj()
		coinObj.setConnect()
		this.add_child(coinObj)

		// 注册一个Rigid2D
		let rigidObj = new IconRigidObj(500,200)
		this.add_child(rigidObj)

		// 注册一个Static2D
		let grass2D = new GrassStaticObj(500,500,"res://assets/grass.png")
		this.add_child(grass2D)
	}

	
	baseControl(){
		let label = new godot.Label()
		label.text = "demo"
		label.margin_left = 20
		label.margin_top = 20
		this.add_child(label)

		let btn = new godot.Button()
		btn.text = "btn"
		btn.margin_left = 40
		btn.margin_top = 40
		btn.rect_scale = new godot.Vector2(5,5)
		this.add_child(btn)
	}

	initContainer(){
		// for(let i = 0;i < 5;i++){
		// 	let btn = new godot.Button()
		// 	btn.text = "Btn-"+i;
		// 	this.add_child(btn)
		// }

		// let hbox = new godot.HBoxContainer()
		// for(let i = 0;i < 10;i++){
		// 	let btn = new godot.Button()
		// 	btn.text = "Btn-"+i;
		// 	hbox.add_child(btn)
		// }
		// this.add_child(hbox)


		// let vbox = new godot.VBoxContainer()
		// for(let i = 0;i < 10;i++){
		// 	let btn = new godot.Button()
		// 	btn.text = "Btn-"+i;
		// 	vbox.add_child(btn)
		// }
		// this.add_child(vbox)

		// let gbox = new godot.GridContainer()
		// gbox.columns = 3
		// for(let i = 0;i < 10;i++){
		// 	let btn = new godot.Button()
		// 	btn.text = "Btn-"+i;
		// 	gbox.add_child(btn)
		// }
		// this.add_child(gbox)

		let cbox = new godot.CenterContainer()
		cbox.rect_size = new godot.Vector2(200,200)
		let btn = new godot.Button()
		btn.text = "btn"
		cbox.add_child(btn)

		this.add_child(cbox)
		
	}

	initTileMap(){
		this.add_child(new CatMap());
	}

}
